Skip to content

ADK changes - #4

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_757876517
May 12, 2025
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_757876517

Conversation

@copybara-service

Copy link
Copy Markdown

ADK changes

PiperOrigin-RevId: 757928489
@copybara-service
copybara-service Bot merged commit 6e98311 into main May 12, 2025
@copybara-service
copybara-service Bot deleted the test_757876517 branch May 12, 2025 22:08
ruslan-kurchenko referenced this pull request in ruslan-kurchenko/adk-java Oct 30, 2025
Issue #4: Client Initialization in SingleFlow
- Implement lazy singleton pattern with double-checked locking
- Add GOOGLE_CLOUD_PROJECT environment variable support
- Add error logging when cache manager initialization fails
- Prevent resource leaks and improve debuggability

Issue #5: Race Condition in Invocation Counter
- Move invocation increment from READ (findLatestCacheMetadata) to WRITE (transferCacheMetadataToResponse)
- Prevents lost updates in multi-pod environments
- Each pod now increments only its own writes (eventually consistent)
- Remove shouldIncrementInvocations() and incrementInvocations() methods

Issue google#13: Concurrent Cache Creation
- Document known limitation with concurrent creation race condition
- Add TODO for future distributed locking implementation
- Probability is low, impact is minimal ($0.24/day for duplicates)
- Duplicates self-correct on next request

These fixes address critical multi-pod deployment issues identified in
code review, improving production reliability and cost predictability.

Testing: ContextCacheProcessorTest (22 tests), GeminiContextCacheManagerTest
(34 tests), CacheMetadataTest all pass with BUILD SUCCESS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 14, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 14, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 14, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
glaforge pushed a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
glaforge pushed a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
glaforge pushed a commit to mekkiamiri/adk-java that referenced this pull request Jun 22, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 24, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 24, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jun 24, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
…ctService

Addresses gemini-code-assist review google#4 and ddobrin maintainer note google#2.

- artifactService(...) now receives ObjectProvider<Storage> instead of
  building its own Storage via StorageOptions.getDefaultInstance(). This
  ensures the googleCloudStorage() bean is the single Storage source — no
  duplicate client when GCS is enabled, user-overridable for testing.
- Throw BeanCreationException at startup when adk.artifacts.gcs-enabled=true
  but adk.artifacts.bucket-name is missing/blank (fail fast).
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
Addresses gemini-code-assist review google#5 and ddobrin maintainer note google#4, plus
a fix-by-side compile bug for VertexAiSessionService.

Session (AdkSessionAutoConfiguration):
- Replace Optional.empty(), Optional.empty() with null, null — the current
  VertexAiSessionService(String, String, @nullable GoogleCredentials,
  @nullable HttpOptions) constructor does not accept Optional<...> so the
  PR did not compile against ADK 1.4.1-SNAPSHOT.
- Throw BeanCreationException at startup when adk.session.type=VERTEX_AI
  is selected without project-id or location.
- Add FIRESTORE enum value with a fail-fast message that directs users to
  the contrib/firestore-session-service module (the Firestore branch
  itself lives in AdkFirestoreSessionAutoConfiguration, gated by
  @ConditionalOnClass).

Memory (AdkMemoryAutoConfiguration):
- Throw BeanCreationException for adk.memory.type=VERTEX_AI (no Vertex AI
  memory service exists in ADK today; silent downgrade to InMemory was
  misleading).
- Add FIRESTORE enum value with the same classpath-missing guidance.

Style across artifacts/session/memory:
- Replace nested if-then-throw patterns with guard clauses + early return.
- Replace static isBlank(String) helper with Optional.ofNullable(...).filter(s -> !s.isBlank())
  Optional pipelines.
- Switch expressions (case X -> ...) for the enum branches.
mekkiamiri added a commit to mekkiamiri/adk-java that referenced this pull request Jul 3, 2026
Addresses ddobrin maintainer note google#4.

AdkRunConfigProperties now binds the operational subset called out by the
reviewer:
- streamingMode (was already there)
- maxLlmCalls (default 500, matching RunConfig.builder())
- toolExecutionMode (default NONE, matching RunConfig.builder())
- saveInputBlobsAsArtifacts (default false)
- autoCreateSession (default false, matching the new RunConfig field
  added since the PR was opened)

AdkRunConfigAutoConfiguration applies all five to RunConfig.builder().

Out of scope for this property surface (left to user-defined RunConfig
beans via @ConditionalOnMissingBean): speechConfig, responseModalities,
inputAudioTranscription, outputAudioTranscription, avatarConfig.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant